<template>
  <div id="app" :class="themeStr">
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  name: "App",
  data() {
    return {
      WXConfig: "",
      themeStr:this.$store.state.theme,
    };
    
  },
  computed:{
    theme(){
      return this.$store.state.theme;
    }
  },
  watch:{
    theme(){
      this.themeStr=this.theme;
    }
  },
  //解决刷新页面vuex数据丢失
  created() {
    //在页面加载时读取sessionStorage里的状态信息
    if (sessionStorage.getItem("store")) {
      this.$store.replaceState(
        Object.assign(
          {},
          this.$store.state,
          JSON.parse(sessionStorage.getItem("store"))
        )
      );
    }
    //在页面刷新时将vuex里的信息保存到sessionStorage里
    window.addEventListener("beforeunload", () => {
      sessionStorage.setItem("store", JSON.stringify(this.$store.state));
    });
  },
  mounted() {
  },
  methods: {
    //获取邀请链接
    async getWXConfig() {
      let params = {
        // token: this.$cookies.get("token")
      };
      const res = await this.$axios.post(this.$api.shareWeixin, params);
      if (res.code == 1) {
        this.WXConfig = res.data.res;
        this.$toast.clear();
      } else {
        this.$toast("获取微信SDK失败：" + res.msg);
        this.$toast.clear();
      }
    }
  }
};
</script>


<style>
@import "./assets/css/public.css";
.van-nav-bar__title {
  color: #202020;
  font-size: 0.18rem;
}
.van-nav-bar .van-icon {
  color: #202020;
}
.van-nav-bar__arrow {
  font-size: 0.18rem;
}
.van-swipe-item img {
  width: 100%;
}
</style>
